﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.Bridge
{

    // "Abstraction"
    public class Abstraction
    {
        // Fields
        protected Implementor implementor;

        // Properties
        public Implementor Implementor
        {
            set { implementor = value; }
        }

        // Methods
        virtual public void Operation()
        {
            implementor.Operation();
        }
    }

    // "Implementor"
    public abstract class Implementor
    {
        // Methods
        abstract public void Operation();
    }

    // "RefinedAbstraction"
    public class RefinedAbstraction : Abstraction
    {
        // Methods
        override public void Operation()
        {
            implementor.Operation();
        }
    }

    // "ConcreteImplementorA"
    public class ConcreteImplementorA : Implementor
    {
        // Methods
        override public void Operation()
        {
            Console.WriteLine("ConcreteImplementorA Operation");
        }
    }

    // "ConcreteImplementorB"
    public class ConcreteImplementorB : Implementor
    {
        // Methods
        override public void Operation()
        {
            Console.WriteLine("ConcreteImplementorB Operation");
        }
    }

}
